#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
class Solution {
public:
    string reverseWords(string& s)
    {
        int j = 0;
        int len = s.size();
        for (int i = 0; i < len; ++i)
        {
            while (i < len && s[i] != ' ')
                ++i;
            reverse(s.begin() + j, s.begin() + i);
            j = i + 1;
        }
        return s;
    }
};